package com.yidu.t299.service.xp.impl;
import com.yidu.t299.dao.xp.LatencyenrolPanelMapper;
import com.yidu.t299.domain.xp.Class;
import com.yidu.t299.domain.xp.LatencyenrolPanel;
import com.yidu.t299.domain.xp.Record;
import com.yidu.t299.domain.xp.School;
import com.yidu.t299.service.xp.LatencyenrolPaneIBiz;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;

/**
 * @descripion:
 * @auth: XuPan
 * @date: 2023/3/10 11:43
 * @version: 1.0
 */
@Service
@Transactional
public class LatencyenrolPaneIBizImpl implements LatencyenrolPaneIBiz {
    @Autowired
    private LatencyenrolPanelMapper latencyenrolPanelMapper;//注入数据


    @Override
    public int deleteByPrimaryKey(Integer clientId) {
        return latencyenrolPanelMapper.deleteByPrimaryKey(clientId);
    }

    @Override
    public int insert(LatencyenrolPanel record) {
        return latencyenrolPanelMapper.insert(record);
    }

    @Override
    public LatencyenrolPanel selectByPrimaryKey(Integer clientId) {
        return latencyenrolPanelMapper.selectByPrimaryKey(clientId);
    }

    @Override
    public List<LatencyenrolPanel> selectByPage(int rows, int page, String condition) {
        return latencyenrolPanelMapper.selectByPage(rows, page, condition);
    }

    @Override
    public int selectCount(String condition) {
        return latencyenrolPanelMapper.selectCount(condition);
    }

    @Override
    public int updateByPrimaryKey(LatencyenrolPanel record) {
        return latencyenrolPanelMapper.updateByPrimaryKey(record);
    }

    @Override
    public String getCondition(LatencyenrolPanel latencyenrolPanel) {
        // 定义条件字符串变量，初始值为空格字符串
        String condition = " ";
        //如果报名对象为空则直接返回条件字符串
        if (latencyenrolPanel == null){
            return condition;
        }
        if (latencyenrolPanel.getClientName() != null && latencyenrolPanel.getClientName().trim().length()!=0){
            condition += " and client_name like '%" + latencyenrolPanel.getClientName() + "%'";
        }
        if (latencyenrolPanel.getClientSex() != null && latencyenrolPanel.getClientSex().trim().length()!=0){
            condition += " and client_sex like '%" + latencyenrolPanel.getClientSex() + "%'";
        }
        if (latencyenrolPanel.getClientAddress() != null && latencyenrolPanel.getClientAddress().trim().length()!=0){
            condition += " and client_address like '%" + latencyenrolPanel.getClientAddress() + "%'";
        }
        //返回条件字符串
        return condition;
    }

    @Override
    public List<School> selectAllGetSchoolName() {
        return latencyenrolPanelMapper.selectAllGetSchoolName();
    }

    @Override
    public List<Class> selectAllGetClassName() {
        return latencyenrolPanelMapper.selectAllGetClassName();
    }

    @Override
    public List<Record> selectAllGetRecordName() {
        return latencyenrolPanelMapper.selectAllGetRecordName();
    }

    @Override
    public int selectBySchoolName(String schoolName) {
        return latencyenrolPanelMapper.selectBySchoolName(schoolName);
    }

    @Override
    public int selectByClassName(String className) {
        return latencyenrolPanelMapper.selectByClassName(className);
    }

    @Override
    public int selectByRecordName(String recordName) {
        return latencyenrolPanelMapper.selectByRecordName(recordName);
    }
}
